package com.flash.materials.service;

import com.flash.materials.domain.Materials;
import com.flash.materials.mapper.MaterialMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @description: TODO
* @author admin
* @date 2023/1/309:52
* @version 1.0
*/
@Service
public class MaterialService {

    @Autowired
    MaterialMapper materialMapper;


    public List<Materials> getAll(Integer materialId){
        List<Materials> all = materialMapper.getAll(materialId);
        return all;
    }

    public String deleteById(Integer id){
        int i = materialMapper.deleteById(id);
        if(i>0){
            return "删除成功";
        }else{
            return "删除失败";
        }
    }

    public String updateById(Materials materials){
        int i = materialMapper.updateById(materials);
        if(i>0){
            return "修改成功";
        }else{
            return "修改失败";
        }
    }

    public String save(Materials materials){
        int save = materialMapper.save(materials);
        if(save>0){
            return "添加成功";
        }else{
            return "添加失败";
        }
    }
}
